#include "grab_widget.h"
#include <QLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>

grab_widget::grab_widget(QPixmap pixmap,QWidget *parent)
{
    QHBoxLayout *main_layout = new QHBoxLayout;
    QVBoxLayout *fun_layout = new QVBoxLayout;
    QHBoxLayout *file_layout = new QHBoxLayout;
    QHBoxLayout *save_layout = new QHBoxLayout;

    QLabel *image_label = new QLabel;
    image_label->setFrameStyle(QFrame::Sunken);
    QPixmap temp = pixmap.scaled(128,128);
    image_label->setPixmap(temp);
    image_label->resize(temp.size());

    QLineEdit *filepath_edit = new QLineEdit;
    QPushButton *filescan_btn = new QPushButton(tr("浏览"));

    QPushButton *save_btn = new QPushButton(tr("保存"));
    QPushButton *discard_btn = new QPushButton(tr("丢弃"));

    main_layout->addWidget(image_label);
    file_layout->addWidget(filepath_edit);
    file_layout->addWidget(filescan_btn);
    save_layout->addWidget(save_btn);
    save_layout->addWidget(discard_btn);
    fun_layout->addLayout(file_layout);
    fun_layout->addLayout(save_layout);
    main_layout->addLayout(fun_layout);

    this->setLayout(main_layout);
    this->setParent(parent,Qt::Window);
}
